
fastlane_version "1.110.0"

default_platform :ios

platform :ios do
  before_all do
    # ENV["SLACK_URL"] = "https://hooks.slack.com/services/..."
    #cocoapods
    
  end

  scheme = “BaxTer”

  def prepare_version(options)
    increment_version_number(
        version_number: options[:version]
    )

    increment_build_number(
        build_number: options[:build]
    )
  end
  


 
  desc "Runs all the tests"
  lane :test do
     xctest(
      workspace: "#{scheme}.xcworkspace",
      scheme: "#{scheme}",
      sdk: 'iphonesimulator’,
      destination: "name=iPhone 5"
    )
  end


  desc "Deploy a new version to the App Store"
   lane :release do
    # match(type: "appstore")
    # snapshot
    

    build_number = Actions.lane_context[Actions::SharedValues::BUILD_NUMBER]
    #git上打上标签
    add_git_tag(tag: "appstore-#{build_number}")
   
    gym # Build your app - more options available
    deliver(force: true)
    # frameit
   end

  
  desc "Deploy a new version to the App Store"
   lane :beta do |options|
        # match(type: "appstore")
        # snapshot

        #prepare_version(options)
      
        full_version = options[:version] + '_' + options[:build]

        gym(scheme: "#{scheme}", 
          workspace: "#{scheme}.xcworkspace",
          silent: true,
          clean: true, 
          output_directory: "./build", 
          output_name: "#{scheme}_#{full_version}.ipa" ,
          configuration: "Release") # 编译打包 ipa 文件

        deliver(force: true, 
          skip_screenshots:true, 
          skip_metadata: true)    # 不上传截屏文件和元数据。


       after_all do |lane|
         # This block is called, only if the executed lane was successful

        # slack(
         #  message: “成功上传app二进制到appStore.”
        # )
        # frameit

        end

       error do |lane, exception|
        # slack(
        #   message: exception.message,
        #   success: false
        # )
       end
    end

end






